Skip to content

Fix _get_members_set to get role name #1993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2025
Merged

Conversation

paulnoirel
Copy link
Contributor

@paulnoirel paulnoirel commented Jul 2, 2025

Description

This PR fixes the role name of a user group member.
It also makes create and update more robust by making sure that workspace-wide users can't be part of groups.

import labelbox as lb
from labelbox.schema.user_group import UserGroup, UserGroupColor, UserGroupMember

ug_id = "8f5ab120-47ba-11f0-b68a-1370de934330"

client = lb.Client(API_KEY)

user_groups = UserGroup.get_user_groups(client)
example_group = next(
    (group for group in user_groups if group.id == ug_id),
    None
)

if example_group:    
    for member in example_group.members:        
        
        role = member.role
        
        print(f"Role ID: {role.uid}")
        print(f"Role Name: {role.name}")
else:
    print("User group not found")

Before change:

Role ID: cjlvi914y1aa20714372uvzjv
Role Name: None
Role ID: cjlvi919b1aa50714k75euii5
Role Name: None
Role ID: cjlvi914y1aa20714372uvzjv
Role Name: None

After change:

Role ID: cjlvi919b1aa50714k75euii5
Role Name: REVIEWER
Role ID: cjlvi914y1aa20714372uvzjv
Role Name: LABELER
Role ID: cjlvi914y1aa20714372uvzjv
Role Name: LABELER

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Document change (fix typo or modifying any markdown files, code comments or anything in the examples folder only)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

New Feature Submissions

  • Does your submission pass tests?
  • Have you added thorough tests for your new feature?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Have you added a Docstring?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

@paulnoirel paulnoirel force-pushed the pno/fix_usergroup_members branch from 6acb3ab to 98f135b Compare July 2, 2025 20:44
@@ -679,6 +677,12 @@ def _get_members_set(
member_nodes = members_data.get("nodes", [])
user_group_roles = members_data.get("userGroupRoles", [])

# Get all roles to map IDs to names
from labelbox.schema.role import get_roles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid localized imports going forward and fix the root cause.

@mrobers1982 mrobers1982 merged commit 06e5429 into develop Jul 8, 2025
40 of 45 checks passed
@mrobers1982 mrobers1982 deleted the pno/fix_usergroup_members branch July 8, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants